package com.szzg10.jsp.chapter10;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;

public class ClassicTagTest4 extends TagSupport {

	private int nestLevel;
	
	@Override
	public int doStartTag() throws JspException {
		nestLevel = 0;
		
		Tag parent = getParent();
		while(parent != null) {
			parent = parent.getParent();
			nestLevel++;
		}
		
		try {
			pageContext.getOut().println("<br>Tag nested level: " + nestLevel);
		}
		catch(IOException e) {
			throw new JspException("IOException- " + e.toString());
		}
		
		return EVAL_BODY_INCLUDE;
	}
}
